package com.example.covid19.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.example.covid19.common.Dto.editdto;
import com.example.covid19.common.lang.Result;
import com.example.covid19.entity.User;
import com.example.covid19.entity.Userf;
import com.example.covid19.mapper.UserfMapper;
import com.example.covid19.service.UserService;
import com.example.covid19.service.UserfService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author BaiZhengChun
 * @since 2022-10-31
 */
@Service
public class UserfServiceImpl extends ServiceImpl<UserfMapper, Userf> implements UserfService {
     private final UserService userService;

     public UserfServiceImpl(UserService userService) {
          this.userService = userService;
     }

     @Override
     public Result edit(editdto editdto){
          User user = new User();
          user.setUserid(Integer.parseInt(StpUtil.getLoginId().toString()));
//          user.setRole(editdto.getRole());
          user.setStudentid(editdto.getStudentid());
          user.setPhone(editdto.getPhone());
          user.setUsername(editdto.getUsername());
          boolean flag = false;
          flag = userService.updateById(user);
          if (flag){
               return Result.success(200,"更新成功",null);
          }
          else {
               return Result.success(200,"更新失败",null);
          }

     }
}
